package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanhua.dubbo.mappers.TopicMapper;
import com.tanhua.model.db.Topic;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;

@DubboService
public class TopicApiImpl implements TopicApi{
    @Autowired
    private TopicMapper topicMapper;

    @Override
    public List<Topic> findByIds(List<Long> questionsIds) {
        List<Topic> list = new ArrayList<>();
        for (Long questionsId : questionsIds) {
            QueryWrapper qw = new QueryWrapper();
            qw.eq("question_id",questionsId);
            Topic topic = topicMapper.selectOne(qw);
            list.add(topic);
        }
        return list;
    }
}
